<template>
	<view class="contoan">
		<top-back-navbar position="fixed" title="商品购买" background="#040A1A" color="#fff"></top-back-navbar>
		<cxsytabbars :current="0" style="position: relative;z-index: 1;"></cxsytabbars>
		<view class="shop_item_box">

			<view class="item" v-for="item in goods_info" @click="todetails(item)">

				<view class="img">
					<image :src="item.thumb" style="width: 100%;height: 100%;" mode=""></image>
				</view>
				<view class="text">
					<view class="title">
						{{item.title}}
					</view>

					<view class="price">
						¥{{item.marketprice}}
					</view>
					<view class="" style="display: flex;color: #fff;width: 100%;">
						<view class=""
							style="font-size: 12px;background-color: #fff;color: #000;padding: 0 6px;border-radius: 50px;">
							立即购买
						</view>
						<view class="" style="font-size: 12px; position: relative;left: 10px;">
							仓量:{{item.cangliang}}
						</view>
					</view>
					<view class="" style="display: flex;color: #fff;width: 100%;margin-top: 5px;">
						<view class="" style="font-size: 12px;">
							库存:{{item.total}}
						</view>
						<view class="" style="font-size: 12px; position: relative;left: 10px;">
							粮票:{{item.kuangshi}}
						</view>
					</view>
				</view>

			</view>


		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {


				page: 1,
				cate: 1294,
				res: [],
				res_list: [],
				goods_info:[]

			};
		},
		onLoad: function(e) {
			console.log(e);
			this.getGoodsList(e.gift)
		},
		methods: {
			getGoodsList(gift) {

				// if(!this.contentText)return;
				uni.showLoading()
				uni.request({
					url: this.$BASE_URL +
						'/index.php?i=2&c=entry&m=ewei_shopv2&do=mobile&r=goods.get_list&keywords=&isrecommand=&ishot=&isnew=&isdiscount=&issendfree=&istime=&order=&by=&merchid=&gift=' +
						gift,

					success: res => {
						let list = Array.isArray(res.data.result.list) ? res.data.result.list : []
						console.log(list);
						
						this.goods_info = list
					},
					fail: () => {},
					complete: () => {
						uni.hideLoading();
					}
				});
			},
			todetails(item) {
				var path = `/pages/goods/detail?goodsid=${item.id}&type='cxsy'`
				uni.navigateTo({
					url: path
				});

			},
		}
	}
</script>

<style lang="less">
	* {
		margin: 0;
		padding: 0;
	}

	page {
		height: 100%;
		width: 100vw;
		height: 180vh;
		background: url('/static/zn/home_page.png') 0 0 no-repeat;
		background-size: 150% 106%;
		position: relative;
		overflow: auto;

	}

	.contoan {
		width: 100vw;
		padding: 40rpx 50rpx;
	}

	.shop_item_box {
		width: 100%;

		.item {
			width: 100%;
			height: 300rpx;
			// border: 1px solid #fff;
			display: flex;
			background: url('../../static/zn/shop_item.png')0 0 no-repeat;
			background-size: 100% 100%;
			margin-top: 25rpx;
			padding: 6px 1px 18px 10px;

			.img {
				width: 50%;
				height: 100%;
				margin-top: 15rpx;
				border: 1px solid red;
			}
		}
	}
	.shop_item_box{
		.title{
			width: 100%;
			text-align: center;
			color: #F4D8B2;
			font-size: 20px;
			font-weight: 800;
		}
		.price{
			width: 100%;
			text-align: center;
			color: #F4D8B2;
			font-size: 20px;
			font-weight: 800;
		}
	}
</style>